Skip to content

Export slot names from http2/core used cross-package#11

Open
jcmallery wants to merge 1 commit into
zellerin:masterfrom
jcmallery:fix/export-cross-package-slot-names
Open

Export slot names from http2/core used cross-package#11
jcmallery wants to merge 1 commit into
zellerin:masterfrom
jcmallery:fix/export-cross-package-slot-names

Conversation

@jcmallery

Copy link
Copy Markdown

Summary

  • Export 6 slot names from http2/core that are referenced via with-slots in http2/stream-overlay (payload-streams.lisp): connection, peer-window-size, window-size, state, output-buffer, network-stream.

Problem

payload-streams.lisp is (in-package http2/stream-overlay) and uses with-slots to access slots defined on classes in http2/core (e.g., flow-control-mixin, http2-stream-minimal, buffered-stream, http2-connection).

Since http2/stream-overlay :uses http2/core, only exported symbols are inherited. These slot names are currently internal to http2/core. Per ANSI CL, with-slots in the http2/stream-overlay package context should intern fresh symbols that don't match the actual slot definitions, causing slot-missing errors at runtime.

This currently works because mgl-pax:define-package happens to make the symbols accessible across packages. But the correctness depends on mgl-pax behavior rather than the ANSI CL package system. Downstream code that subclasses http2-stream from other packages encounters this issue and requires slot-missing workarounds.

Fix

Add :export for the 6 slot names to the http2/core package definition. This makes the cross-package with-slots references correct per ANSI CL regardless of which defpackage implementation is used.

Test plan

  • Verify existing tests pass with the export
  • Verify (eq (find-symbol "PEER-WINDOW-SIZE" :http2/stream-overlay) (find-symbol "PEER-WINDOW-SIZE" :http2/core)) returns T

@jcmallery

Copy link
Copy Markdown
Author

Context on why this is needed:

payload-streams.lisp is (in-package http2/stream-overlay) and uses with-slots to reference slot names defined on classes in http2/core -- for example, peer-window-size and window-size on flow-control-mixin, connection and state on http2-stream-minimal, output-buffer on buffered-stream, and network-stream on http2-connection.

Since http2/stream-overlay :uses http2/core, only exported symbols are inherited per ANSI CL. These slot names are currently internal to http2/core, so the reader should intern fresh symbols in http2/stream-overlay that are not eq to the actual slot-definition names. CLOS with-slots expands to slot-value calls keyed by symbol identity, so the wrong symbol means slot-missing.

This works today because mgl-pax:define-package happens to make the symbols accessible. But downstream code that subclasses http2-stream from other packages (using standard defpackage) encounters this and needs slot-missing workarounds. We hit this in CL-HTTP's HTTP/2 client, where cl-http-client-stream inherits from http2/client:client-stream.

The fix is minimal -- just export the 6 slot names that are referenced cross-package.

payload-streams.lisp (in-package http2/stream-overlay) references slot
names connection, peer-window-size, state, output-buffer, network-stream,
and window-size via with-slots.  These symbols are internal to http2/core.

Per ANSI CL, :use only inherits exported symbols.  Currently this works
because mgl-pax:define-package shares all symbols, but with standard
defpackage the with-slots forms would intern fresh symbols in
http2/stream-overlay that don't match the actual slot names, causing
slot-missing errors at runtime.

Export the six slot names from http2/core so cross-package with-slots
references resolve correctly regardless of the package definition macro
used.  This also enables downstream users who subclass http2-stream from
other packages to access these slots without double-colon qualification.
@jcmallery jcmallery force-pushed the fix/export-cross-package-slot-names branch from 849847b to 7904ec5 Compare April 7, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant